package com.design.ObserverMode.simpleDemo;

import java.util.ArrayList;
import java.util.List;

public class MyObserverImpl implements MyObserver{

    private List<IObserverService> services = new ArrayList<>();

    @Override
    public void reg(IObserverService service) {
        services.add(service);
    }

    @Override
    public void remove(IObserverService service) {
        services.remove(service);
    }

    @Override
    public void notifyAll(String msg) {
        for (IObserverService observerService : services) {
            observerService.todo(msg);
        }
    }
}
